﻿using AuthCenter_HuangJingtao.Domain;
using AuthCenter_HuangJingtao.ErrorCode;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using AuthCenter_HuangJingtao.Read.Api.Application.Command.AppaLL;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace AuthCenter_HuangJingtao.Read.Api.Application.CommandHandler.AppHandler
{
    public class FirstAppShowCommandHandler : IRequestHandler<FirstAppShowCommand, ApiResult<App>>
    {
        IBaseReponsitory<App> Apps;

        public FirstAppShowCommandHandler(IBaseReponsitory<App> Apps)
        {
            this.Apps = Apps;
        }

        public async Task<ApiResult<App>> Handle(FirstAppShowCommand request, CancellationToken cancellationToken)
        {
            var list =await Apps.GetQuery().FirstOrDefaultAsync(c=>c.App_Id==request.id);
            return new ApiResult<App>
            {
                Code=ApiEnum.Success,
                Message="获取成功",
                Data=list
            };

        }
    }
}
